package ModelLayer;
import java.util.ArrayList;

public class StaffContainer
{
    public ArrayList<Staff> staffGroupContainer;
    public static StaffContainer instance;
    public StaffContainer()
    {
        staffGroupContainer = new ArrayList<Staff>();
    }
    public static StaffContainer getSingelton()
    {
        if(instance == null)
        {
            instance = new StaffContainer();
        }
        return instance;
    }
    public void addStaff(Staff staff)
    {
        staffGroupContainer.add(staff);
    }
    public Staff findStaff(String phone)
    {
        int index = 0;
        boolean found = false;
        while(index < staffGroupContainer.size() && !found)
        {
            if(staffGroupContainer.get(index).getPhoneNo().equals(phone))
            {
                found = true;
            }
            else
            {
                index++;
            }
        }
        return staffGroupContainer.get(index);
    }
    public boolean deleteStaff(String phone)
    {
        int index = 0;
        boolean found = false;
        while(index < staffGroupContainer.size() && !found)
        {
            if(staffGroupContainer.get(index).getPhoneNo().equals(phone))
            {
                staffGroupContainer.remove(index);
                found = true;
            }
            else
            {
                index++;
            }
        }
        return found;
    }
    public ArrayList<Staff> listAllStaff()
    {
        return staffGroupContainer;
    }

    
   
}
